function onlyNumbersPointDano(evt)
{
	var keyPressed = (evt.which) ? evt.which : event.keyCode
			return !(keyPressed > 31 && (keyPressed < 48 || keyPressed > 57) && keyPressed != 46 );
}
function onlyNumbersDano(evt)
{
	var keyPressed = (evt.which) ? evt.which : event.keyCode
			return !(keyPressed > 31 && (keyPressed < 48 || keyPressed > 57));
}

function categorySubmit() {
	$("#categoryList").change(function() {
	    $("#catSelect").submit();
	});
}

function hideDirection() {
	if ($("#orderParameters option:selected").text() == "None") {
		$("#direction").css({visibility: "hidden"});
	} else {
		$("#direction").css({visibility: "visible"});
	}
	$("#orderParameters").change(function () {
		if ($("#orderParameters option:selected").text() == "None") {
			$("#direction").css({visibility: "hidden"});
		} else {
			$("#direction").css({visibility: "visible"});
		}
	});
}

function hideCalification() {
	if ($("#confirmation option:selected").text() == "Not yet confirmed") {
		$("#calification").css({visibility: "hidden"});
		$("#calificationlbl").css({visibility: "hidden"});
	} else {
		$("#calification").css({visibility: "visible"});
		$("#calification").css({visibility: "visible"});
	}
	$("#confirmation").change(function () {
		if ($("#confirmation option:selected").text() == "Not yet confirmed") {
			$("#calification").css({visibility: "hidden"});
			$("#calificationlbl").css({visibility: "hidden"});
		} else {
			$("#calification").css({visibility: "visible"});
			$("#calificationlbl").css({visibility: "visible"});
		}
	});
}

function datePicker() {
	$(function() {
		$( ".datepicker" ).datepicker({ dateFormat: "dd/mm/yy"});
	});
}

function showPopup(name){
	$('.overlay').fadeIn(); 
	$('.'+name).fadeIn(); 
	$('.'+name+' input[type="text"]').focus();
	return false;	
}


function flagResult(resultId, flag, resultsId){
	$.ajax({
		url: "../data/FlagResult",
		dataType: 'text',
		type : 'get',
		data: "result_item_id="+resultId+"&flag="+(!flag)+"&result_id="+resultsId,
		beforeSend: function(){
			$("#star"+resultId).addClass("starloading");
		},
		success: function(data){
        	if ($("#star"+resultId).hasClass("starfalse")){
        		$("#star"+resultId).removeClass("starfalse");
        		$("#star"+resultId).addClass("startrue");
        	}else if ($("#star"+resultId).hasClass("startrue")){
        		$("#star"+resultId).removeClass("startrue");
        		$("#star"+resultId).addClass("starfalse");
        	}
        	$("#star"+resultId).removeClass("starloading");
        },
        error: function(){
        	alert("Hubo un error al marcar como preferido");
        }
	});
}


function selectAll(){
	jQuery(".checkuser").attr("checked",true);
}

function unselectAll(){
	jQuery(".checkuser").attr("checked",false);
}
